package com.peng.controller;

import com.peng.entity.User;
import com.peng.service.FileService;
import com.peng.service.UserService;
import com.peng.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/oss/file")
public class OssController {

    @Autowired
    private FileService fileService;

    @PostMapping("/upload")
    public Result upload(MultipartFile file, String model){
        // 返回上传到oss的路径
        String url = fileService.upload(file, model);
        return Result.ok(url).message("文件上传成功");
    }
}
